### Parameters

!define TOASTMASTERS_TIMER_VERSION "1.1"

!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\ToastmastersTimer"

!define STARTMENU_DIR "$SMPROGRAMS\Toastmasters Timer"

!define TOASTMASTERS_TIMER_CMD "$INSTDIR\ToastmastersTimer.exe"

!define TOASTMASTERS_TIMER_LNK "ToastmastersTimer.lnk"

# App name
Name "Toastmasters Color Timer"

# Name of installer file
OutFile "ToastmastersTimer-${TOASTMASTERS_TIMER_VERSION}.exe"

# The default installation directory
InstallDir $PROGRAMFILES\ToastmastersTimer

# Macros
!include "Sections.nsh"

Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

# Icons
Icon "timer.ico"
UninstallIcon "timer.ico"

# Use XP ui when available
XPStyle on

### Sections
Section "-Install"
    # Install files
    SetOutPath $INSTDIR
    WriteUninstaller $INSTDIR\uninst.exe
    File dist\*.exe
    File dist\*.pyd 
    File dist\*.dll 
    File dist\*.zip 
    File timer.ico

    # Shortcuts
    SetShellVarContext all

    # Start menu shortcuts
    CreateDirectory "${STARTMENU_DIR}"
    CreateShortCut "${STARTMENU_DIR}\${TOASTMASTERS_TIMER_LNK}" "${TOASTMASTERS_TIMER_CMD}"

    # Desktop shortcuts
    CreateShortCut "$DESKTOP\${TOASTMASTERS_TIMER_LNK}" "${TOASTMASTERS_TIMER_CMD}"

    # Uninstaller registry keys
    WriteRegStr HKLM ${UNINSTALL_KEY} "DisplayName" "Toastmasters Color Timer"
    WriteRegStr HKLM ${UNINSTALL_KEY} "UninstallString" "$INSTDIR\uninst.exe"
SectionEnd

Section "un.Install"
    # Remove files
    Delete $INSTDIR\*.exe
    Delete $INSTDIR\*.pyd
    Delete $INSTDIR\*.dll
    Delete $INSTDIR\*.zip
    RMDir $INSTDIR

    # Remove shortcuts
    SetShellVarContext all
    Delete "$DESKTOP\${TOASTMASTERS_TIMER_LNK}"
    RMDir /r "${STARTMENU_DIR}"

    DeleteRegKey HKLM ${UNINSTALL_KEY}
SectionEnd

# vi: ts=4 sw=4 et
